package _220308;

import java.util.Scanner;

/**
 * @author ShadowLim
 *  纯质数：欧拉筛选法求素数
 */
public class _纯质数 {
    static int n = 20210605;
    static int[] primes = new  int[n + 1];
    static int[] vis = new int[n + 1];

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        for (int i = 2; i <= n; i++) {
            if (vis[i] == 0) {
                primes[++primes[0]] = i;
            }
            for (int j = 1; j <= primes[0] && i * primes[j] < n; j++) {
                vis[i * primes[j]] = 1;
                if (i % primes[j] == 0) {
                    break;
                }
            }
        }
        int ans = 0;
        for (int i = 1; i <= primes[0]; i++) {
            if (f(primes[i])) {
                ans++;
            }
        }
        System.out.println(ans);
    }

    private static boolean f(int n) {
        while (n != 0) {
            int t = n % 10;
            n /= 10;
            if (t == 0 || t == 1 || t == 4 || t == 6 || t == 8 || t == 9) {
                return false;
            }
        }
        return true;
    }
}
